﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using CoreSolution.IService.Common;
using CoreSolution.Tools.WebResult;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace CoreSolution.Vip.Controllers
{
    [EnableCors("AllowAllOrigin")]
    [Produces("application/json")]
    [Route("api/MediaCenter")]
    public class MediaCenterController : ControllerBase
    {
        private readonly IFileUploadService _IFileUploadService;

        public MediaCenterController(IFileUploadService iFileUploadService)
        {
            _IFileUploadService = iFileUploadService;
        }

        [Route("PostFile")]
        [HttpPost]
        public IActionResult PostFile(IFormFileCollection fileT)
        {
            var files = Request.Form.Files;
            var result = _IFileUploadService.UploadFile(files);
            if (result.success)
            {
                return AjaxHelper.JsonResult(HttpStatusCode.OK, result.message, result.fileReturn);
            }
            return AjaxHelper.JsonResult(HttpStatusCode.BadRequest, result.message);
        }
    }
}